package com.situ.mall.base.mapper;

import com.situ.mall.base.entity.Cart;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.situ.mall.base.vo.CartVO;
import com.situ.mall.base.vo.OrderVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author darling
 * @since 2023-04-02
 */
public interface CartMapper extends BaseMapper<Cart> {

    @Select("SELECT * FROM t_cart WHERE product_id = #{productId}  AND member_id = #{id}")
    Cart selectByMemberIDAndProductID(@Param("id") Integer id, @Param("productId") Integer productId);

    @Update("UPDATE t_cart SET count = count + 1 WHERE id = #{id}")
    void updateAmount(Integer id);

    List<CartVO> selectCartList(Integer mId);

    @Delete("DELETE FROM t_cart WHERE id = #{cartId}")
    void doDelById(Integer cartId);

    @Update("UPDATE t_cart SET count = count + 1")
    void add(Integer id);

    @Update("UPDATE t_cart SET count = count - 1")
    void sub(Integer id);

    OrderVO doListByIds(Integer id);


}
